package com.gongren.project.job.oss;

import com.alibaba.dubbo.config.annotation.Reference;
import com.gongren.project.odd.job.rpc.api.oss.service.taskRpc.IJobCountTaskRpcService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Author houzhong
 * @Date 2017/9/1 13:04
 */
@Component("jobCountTask")
public class JobCountTask {

    private static Logger LOGGER = LoggerFactory.getLogger(JobCountTask.class);

    @Reference
    private IJobCountTaskRpcService jobCountTaskRpcService;

    /**
     * 零工订单统计1.2
     * 每天凌晨一点执行
     */
    @Transactional
    //@Scheduled(cron = "0 0 1 * * ? ")
    public void excuteJobTaskCountTask(){

        LOGGER.info("JobCountTask and excuteJobTaskCountTask start");
        try {
            jobCountTaskRpcService.findAllExcuteJobTaskCountTask();

            LOGGER.info("JobCountTask and excuteJobTaskCountTask end");
        }catch (Exception e) {
            LOGGER.error("JobCountTask and excuteJobTaskCountTask：", e);
        }
    }

    /**
     * 日报1.2
     * 每天凌晨一点执行
     */
    @Transactional
    //@Scheduled(cron = "0 0 1 * * ? ")
    public void excuteJobTaskDailyTask(){

        LOGGER.info("JobCountTask and excuteJobTaskDailyTask start ");
        try {
            jobCountTaskRpcService.findAllExcuteJobTaskDailyTask();

            LOGGER.info("JobCountTask and excuteJobTaskDailyTask end ");
        }catch (Exception e) {
            LOGGER.error("JobCountTask and excuteJobTaskDailyTask：{}", e);
        }
    }

}
